package com.bootdo.wx.service.impl;

import com.bootdo.common.utils.PageHelperUtils;
import com.bootdo.common.utils.R;
import com.bootdo.wx.dao.CmsProblemDao;
import com.bootdo.wx.domain.CmsProblemDO;
import com.bootdo.wx.service.CmsProblemService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;



@Service
public class CmsProblemServiceImpl implements CmsProblemService {
	@Autowired
	private CmsProblemDao cmsProblemDao;
	
	@Override
	public CmsProblemDO get(String id){
		return cmsProblemDao.get(id);
	}
	
	@Override
	public List<CmsProblemDO> list(Map<String, Object> map){
		return cmsProblemDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return cmsProblemDao.count(map);
	}
	
	@Override
	public int save(CmsProblemDO cmsProblem){
		return cmsProblemDao.save(cmsProblem);
	}
	
	@Override
	public int update(CmsProblemDO cmsProblem){
		return cmsProblemDao.update(cmsProblem);
	}
	
	@Override
	public int remove(String id){
		return cmsProblemDao.remove(id);
	}
	
	@Override
	public int batchRemove(String[] ids){
		return cmsProblemDao.batchRemove(ids);
	}

    @Override
    public List<CmsProblemDO> likeList(Map<String, Object> map){
        return cmsProblemDao.likeList(map);
    }

	@Override
	public R getProblemList(Map<String, Object> params) {
		PageHelperUtils.page(params);
		params.put("delFlag", "0");
		params.put("sort", "ca_at");
		params.put("order", "desc");
		List<Map<String, Object>> mapList = cmsProblemDao.getProblemList(params);
		PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(mapList);
		
		return R.ok().put("data", pageInfo);
	}

	@Override
	public R getProblemInfo(Map<String, Object> params) {
		CmsProblemDO cmsProblemDO = cmsProblemDao.get(params.get("id").toString());
		return R.ok().put("data", cmsProblemDO);
	}

    @Override
    public R getProblemNameByClassId(Map<String, Object> params) {

		List<Map<String, Object>> mapList =  cmsProblemDao.getProblemNameByClassId(params);
		return R.ok().put("data",mapList);
    }

}
